#include <iostream>
using namespace std;

const int kMaxN = 2e5 + 10;
const int kInf = 1e9;

int a[kMaxN];

bool Check(int l, int r, int ans, int n) {
  int min_a = r, max_a = l;
  bool has_toy = false;

  for (int i = 0; i < n; i++) {
    if (a[i] >= l && a[i] <= r) {
      min_a = min(min_a, a[i]);
      max_a = max(max_a, a[i]);
      has_toy = true;
    }
  }
  return !has_toy || max_a - min_a <= 2 * ans;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;
  for (cin >> T; T; T--) {
    int n, min_a = kInf, max_a = 0;

    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      min_a = min(min_a, a[i]);
      max_a = max(max_a, a[i]);
    }
    int l = 0, r = (max_a - min_a) / 6 + 1;
    while (l < r) {
      int m = (l + r) >> 1;
      if (Check(min_a + 2 * m + 1, max_a - 2 * m - 1, m, n)) {
        r = m;
      } else {
        l = m + 1;
      }
    }
    cout << l << "\n";
  }
  return 0;
}